package com.example.win.android_banduyujia.peopleactivity.activity.activity.payactivtiy;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.example.win.android_banduyujia.R;
import com.example.win.android_banduyujia.http.request.SavePayRequest;
import com.example.win.android_banduyujia.http.response.BaseHttpResponse;
import com.example.win.android_banduyujia.lib.util.StrUtils;
import com.example.win.android_banduyujia.peopleactivity.ui.activity.BaseTitleBarActivity;
import com.example.win.android_banduyujia.venuesactivity.activity.payactivity.PayActivity;
import com.example.win.android_banduyujia.venuesactivity.activity.payactivity.WechatActivity;

/**
 * Created by Win on 2015/9/5.
 */
public class ShiftoutActivity extends BaseTitleBarActivity implements View.OnClickListener {

    private TextView mTxtPay, mTxtWechat;
    private EditText shiftout;
    private Button   mBtnout;

    private String    mBinding;
    private String    mToken;
    private String    mCode;
    private String    mRealname;
    private String    mAccount;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.title_shift_out);

        InitTitles();
        InitViews();
    }

    private void InitTitles() {
        showLeftBackButton();
        setTitle(R.string.text_view_roll_out);
        setRightTextViewListener(R.string.text_view_roll_out_instructions, mRightListener);
    }

    public View.OnClickListener  mRightListener = new View.OnClickListener(){

        @Override
        public void onClick(View v) {

        }
    };

    private void InitViews() {
        mTxtPay = (TextView)findViewById(R.id.title_list_text_pay);
        mTxtWechat = (TextView)findViewById(R.id.title_image_venues_wechat);
        shiftout = (EditText)findViewById(R.id.fragment_pay_edit);
        mBtnout = (Button)findViewById(R.id.button_venues_shift_out);

        mTxtPay.setOnClickListener(this);
        mTxtWechat.setOnClickListener(this);
       // shiftout.setOnClickListener(this);
        mBtnout.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.title_list_text_pay:
                gotoPayActivity();
                break;
            case R.id.title_image_venues_wechat:
                gotoWechatActivity();
                break;
            case R.id.button_venues_shift_out:
                gotoShiftActivity();
                break;
        }
    }

    private void gotoPayActivity() {
          //  mTxtPay.setText(" ");
            SavePayRequest request = new SavePayRequest(mToken,mCode,mRealname,mAccount);
            mAsycHttpRequest.doRequest(this, request, BaseHttpResponse.class, mPayHandler, true);

        startActivity(new Intent(this, PayActivity.class));
    }

    private Handler mPayHandler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            setResult(Activity.RESULT_OK);
          //  finish();
        }
    };

    private void gotoWechatActivity() {
        startActivity(new Intent(this, WechatActivity.class));
    }

    private void gotoShiftActivity() {

    }
}
